package com.ruoyi.system.controller;


import com.ruoyi.common.annotation.AnonymousAccess;
import com.ruoyi.common.vo.Result;
import com.ruoyi.system.domain.vo.SendVerifyCodeVo;
import com.ruoyi.system.service.IVerifyCodeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.security.PermitAll;

@RequestMapping("/system/verifyCode")
@Api(tags="发送验证码")
@RestController
public class SendVerifyController {


    @Autowired
    private IVerifyCodeService sendVerifyService;

    @PostMapping("/sendVerify")
    @AnonymousAccess
    @ApiOperation(value="验证码-发送验证码", notes="验证码-发送验证码")
    public Result<?> sendVerify(@RequestBody SendVerifyCodeVo sendVerifyCodeVo) {
        sendVerifyService.sendVerifyCode(sendVerifyCodeVo);
        return Result.OK("验证码发送成功");
    }

    @PostMapping("/submitVerify")
    @AnonymousAccess
    @ApiOperation(value="验证码-提交", notes="验证码-提交")
    public Result<?> submitVerify(@RequestBody SendVerifyCodeVo sendVerifyCodeVo) {
        return sendVerifyService.submitVerify(sendVerifyCodeVo);
    }
}
